<html>
<head><meta charset="utf-8"><title>I-prioritize #78115 ICE: variable should be placed in scope… · t-compiler/wg-prioritization/alerts · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/245100-t-compiler/wg-prioritization/alerts/index.html">t-compiler/wg-prioritization/alerts</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize.20.2378115.20ICE.3A.20variable.20should.20be.20placed.20in.20scope.E2.80.A6.html">I-prioritize #78115 ICE: variable should be placed in scope…</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="213836958"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize%20%2378115%20ICE%3A%20variable%20should%20be%20placed%20in%20scope%E2%80%A6/near/213836958" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> triagebot <a href="https://rust-lang.github.io/zulip_archive/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize.20.2378115.20ICE.3A.20variable.20should.20be.20placed.20in.20scope.E2.80.A6.html#213836958">(Oct 19 2020 at 19:59)</a>:</h4>
<p><span class="user-group-mention" data-user-group-id="3111">@WG-prioritization/alerts</span> issue <a href="https://github.com/rust-lang/rust/issues/78115">#78115</a> has been requested for prioritization.</p>
<h1><a href="https://forge.rust-lang.org/compiler/prioritization/procedure.html#assign-priority-to-unprioritized-issues-with-i-prioritize-label">Procedure</a></h1>
<ul>
<li>Priority?</li>
<li>Regression?</li>
<li>Notify people/groups?</li>
<li>Needs <code>I-nominated</code>?</li>
</ul>



<a name="213837288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize%20%2378115%20ICE%3A%20variable%20should%20be%20placed%20in%20scope%E2%80%A6/near/213837288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hameer Abbasi <a href="https://rust-lang.github.io/zulip_archive/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize.20.2378115.20ICE.3A.20variable.20should.20be.20placed.20in.20scope.E2.80.A6.html#213837288">(Oct 19 2020 at 20:01)</a>:</h4>
<p>P-high at least? Sound like a regression from stable and could be a pretty common pattern.</p>



<a name="213837685"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize%20%2378115%20ICE%3A%20variable%20should%20be%20placed%20in%20scope%E2%80%A6/near/213837685" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Léo Lanteri Thauvin <a href="https://rust-lang.github.io/zulip_archive/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize.20.2378115.20ICE.3A.20variable.20should.20be.20placed.20in.20scope.E2.80.A6.html#213837685">(Oct 19 2020 at 20:04)</a>:</h4>
<p>This is invalid code though, right?</p>



<a name="213837702"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize%20%2378115%20ICE%3A%20variable%20should%20be%20placed%20in%20scope%E2%80%A6/near/213837702" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Léo Lanteri Thauvin <a href="https://rust-lang.github.io/zulip_archive/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize.20.2378115.20ICE.3A.20variable.20should.20be.20placed.20in.20scope.E2.80.A6.html#213837702">(Oct 19 2020 at 20:04)</a>:</h4>
<p>Can this happen with valid code?</p>



<a name="213837938"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize%20%2378115%20ICE%3A%20variable%20should%20be%20placed%20in%20scope%E2%80%A6/near/213837938" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Stu <a href="https://rust-lang.github.io/zulip_archive/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize.20.2378115.20ICE.3A.20variable.20should.20be.20placed.20in.20scope.E2.80.A6.html#213837938">(Oct 19 2020 at 20:06)</a>:</h4>
<p>Yes it can.</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">struct</span> <span class="nc">Foo</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">a</span>: <span class="kt">bool</span><span class="p">,</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">foo</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Foo</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">a</span>: <span class="nc">true</span><span class="w"> </span><span class="p">};</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">s</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">async</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="k">match</span><span class="w"> </span><span class="n">foo</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="n">Foo</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">Foo</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="kc">true</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="p">};</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="213838057"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize%20%2378115%20ICE%3A%20variable%20should%20be%20placed%20in%20scope%E2%80%A6/near/213838057" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Léo Lanteri Thauvin <a href="https://rust-lang.github.io/zulip_archive/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize.20.2378115.20ICE.3A.20variable.20should.20be.20placed.20in.20scope.E2.80.A6.html#213838057">(Oct 19 2020 at 20:07)</a>:</h4>
<p><del>If bisection is correct it broke a while ago though</del> Nvm can't read</p>



<a name="213838270"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize%20%2378115%20ICE%3A%20variable%20should%20be%20placed%20in%20scope%E2%80%A6/near/213838270" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Léo Lanteri Thauvin <a href="https://rust-lang.github.io/zulip_archive/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize.20.2378115.20ICE.3A.20variable.20should.20be.20placed.20in.20scope.E2.80.A6.html#213838270">(Oct 19 2020 at 20:09)</a>:</h4>
<blockquote>
<p>The ICE occurs if you're using a match guard and binding the same variable name in both sides of an "or" in a match pattern.</p>
</blockquote>
<p>Looks like a fairly serious regression indeed, I think <code>P-high</code> is fine but do you think it warrants <code>P-critical</code>?</p>



<a name="213838330"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize%20%2378115%20ICE%3A%20variable%20should%20be%20placed%20in%20scope%E2%80%A6/near/213838330" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Stu <a href="https://rust-lang.github.io/zulip_archive/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize.20.2378115.20ICE.3A.20variable.20should.20be.20placed.20in.20scope.E2.80.A6.html#213838330">(Oct 19 2020 at 20:09)</a>:</h4>
<p>Probably even <code>P-critical</code>? This code seems very likely to happen in normal code you would write</p>



<a name="213838376"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize%20%2378115%20ICE%3A%20variable%20should%20be%20placed%20in%20scope%E2%80%A6/near/213838376" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Léo Lanteri Thauvin <a href="https://rust-lang.github.io/zulip_archive/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize.20.2378115.20ICE.3A.20variable.20should.20be.20placed.20in.20scope.E2.80.A6.html#213838376">(Oct 19 2020 at 20:09)</a>:</h4>
<p>Let me do a quick bisection check</p>



<a name="213838761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize%20%2378115%20ICE%3A%20variable%20should%20be%20placed%20in%20scope%E2%80%A6/near/213838761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Léo Lanteri Thauvin <a href="https://rust-lang.github.io/zulip_archive/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize.20.2378115.20ICE.3A.20variable.20should.20be.20placed.20in.20scope.E2.80.A6.html#213838761">(Oct 19 2020 at 20:12)</a>:</h4>
<p><span class="user-mention" data-user-id="230287">@Stu</span> Your last snippet doesn't compile on stable though:</p>
<div class="codehilite" data-code-language="Text only"><pre><span></span><code>error[E0004]: non-exhaustive patterns: `Foo { .. }` not covered
 --&gt; src/main.rs:8:15
  |
1 | / struct Foo {
2 | |     a: bool,
3 | | }
  | |_- `Foo` defined here
...
8 |           match foo {
  |                 ^^^ pattern `Foo { .. }` not covered
  |
  = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
  = note: the matched value is of type `Foo`
</code></pre></div>



<a name="213838793"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize%20%2378115%20ICE%3A%20variable%20should%20be%20placed%20in%20scope%E2%80%A6/near/213838793" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Stu <a href="https://rust-lang.github.io/zulip_archive/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize.20.2378115.20ICE.3A.20variable.20should.20be.20placed.20in.20scope.E2.80.A6.html#213838793">(Oct 19 2020 at 20:12)</a>:</h4>
<p>the ICE is only on nightly, so I tested it on nightly</p>



<a name="213839060"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize%20%2378115%20ICE%3A%20variable%20should%20be%20placed%20in%20scope%E2%80%A6/near/213839060" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yuki Okushi <a href="https://rust-lang.github.io/zulip_archive/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize.20.2378115.20ICE.3A.20variable.20should.20be.20placed.20in.20scope.E2.80.A6.html#213839060">(Oct 19 2020 at 20:15)</a>:</h4>
<p>wildcard pattern is required, as diags said</p>



<a name="213839204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize%20%2378115%20ICE%3A%20variable%20should%20be%20placed%20in%20scope%E2%80%A6/near/213839204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Stu <a href="https://rust-lang.github.io/zulip_archive/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize.20.2378115.20ICE.3A.20variable.20should.20be.20placed.20in.20scope.E2.80.A6.html#213839204">(Oct 19 2020 at 20:16)</a>:</h4>
<p>But it still panics on nightly, even with a wildcard pattern</p>



<a name="213839521"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize%20%2378115%20ICE%3A%20variable%20should%20be%20placed%20in%20scope%E2%80%A6/near/213839521" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Stu <a href="https://rust-lang.github.io/zulip_archive/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize.20.2378115.20ICE.3A.20variable.20should.20be.20placed.20in.20scope.E2.80.A6.html#213839521">(Oct 19 2020 at 20:18)</a>:</h4>
<p>So what should we pick? <code>critical</code> or <code>high</code>? I'm fine with both but I would label it as <code>critical</code></p>



<a name="213839564"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize%20%2378115%20ICE%3A%20variable%20should%20be%20placed%20in%20scope%E2%80%A6/near/213839564" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Léo Lanteri Thauvin <a href="https://rust-lang.github.io/zulip_archive/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize.20.2378115.20ICE.3A.20variable.20should.20be.20placed.20in.20scope.E2.80.A6.html#213839564">(Oct 19 2020 at 20:19)</a>:</h4>
<p>Also ICEs in <code>async fn</code>s</p>



<a name="213839589"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize%20%2378115%20ICE%3A%20variable%20should%20be%20placed%20in%20scope%E2%80%A6/near/213839589" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Léo Lanteri Thauvin <a href="https://rust-lang.github.io/zulip_archive/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize.20.2378115.20ICE.3A.20variable.20should.20be.20placed.20in.20scope.E2.80.A6.html#213839589">(Oct 19 2020 at 20:19)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">async</span><span class="w"> </span><span class="k">fn</span> <span class="nf">bar</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">match</span><span class="w"> </span><span class="n">foo</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">Foo</span>::<span class="n">A</span><span class="p">(</span><span class="n">a</span><span class="p">)</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">Foo</span>::<span class="n">B</span><span class="p">(</span><span class="n">a</span><span class="p">)</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="kc">true</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="w">        </span><span class="n">_</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>

<p>Triggers an ICE</p>



<a name="213839639"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize%20%2378115%20ICE%3A%20variable%20should%20be%20placed%20in%20scope%E2%80%A6/near/213839639" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Léo Lanteri Thauvin <a href="https://rust-lang.github.io/zulip_archive/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize.20.2378115.20ICE.3A.20variable.20should.20be.20placed.20in.20scope.E2.80.A6.html#213839639">(Oct 19 2020 at 20:19)</a>:</h4>
<p>So I think it should be <code>P-critical</code></p>



<a name="213839741"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize%20%2378115%20ICE%3A%20variable%20should%20be%20placed%20in%20scope%E2%80%A6/near/213839741" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> triagebot <a href="https://rust-lang.github.io/zulip_archive/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize.20.2378115.20ICE.3A.20variable.20should.20be.20placed.20in.20scope.E2.80.A6.html#213839741">(Oct 19 2020 at 20:20)</a>:</h4>
<p>Issue <a href="https://github.com/rust-lang/rust/issues/78115">#78115</a>'s prioritization request has been removed.</p>



<a name="213849790"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize%20%2378115%20ICE%3A%20variable%20should%20be%20placed%20in%20scope%E2%80%A6/near/213849790" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Léo Lanteri Thauvin <a href="https://rust-lang.github.io/zulip_archive/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize.20.2378115.20ICE.3A.20variable.20should.20be.20placed.20in.20scope.E2.80.A6.html#213849790">(Oct 19 2020 at 21:39)</a>:</h4>
<p>(Filed a potential fix: <a href="https://github.com/rust-lang/rust/issues/78121">#78121</a>)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>